/**
 * 
 */
package sourceFiles;

import Exceptions.InvalidChildID;
import Exceptions.InvalidRideId;
import Exceptions.TicketDoesntExist;
import Exceptions.CentralComputerExceptions.ChildAgeDoesntMatch;
import Exceptions.CentralComputerExceptions.ChildDoesntHaveTicket;
import Exceptions.CentralComputerExceptions.ChildHeightDoesntMatch;
import Exceptions.CentralComputerExceptions.ChildIDDoesntExist;
import Exceptions.CentralComputerExceptions.RideIDDoesntExist;
import RideExceptions.ChildAlreadyInRideException;
import RideExceptions.ChildNotInRideException;
import RideExceptions.RideActiveException;
import RideExceptions.RideInactiveException;

/**
 * A class representing a simple gate in the park. a gate can open, close, and
 * pass a child through it (after a confirmation sequence)
 * 
 * @author LASO-Team
 * 
 */
public abstract class Gate implements IGate {

	private Boolean isOpened;
	private IRide ride;

	/**
	 * A simple constructor for the parameters of the gate (a Gate is closed
	 * upon creation)
	 * 
	 * @param ride
	 *            the ride that the gate is attached to.
	 */
	public Gate(IRide ride) {
		super();
		this.ride = ride;
		isOpened = false;
	}

	/*--------------------------------------------------------------------------*/

	/*
	 * (non-Javadoc)
	 * 
	 * @see sourceFiles.IGate#IsGateOpened()
	 */
	public Boolean IsGateOpened() {
		return isOpened;
	}

	/**
	 * Getter for the parent Ride this gate belongs to
	 * 
	 * @return the parent ride
	 */
	protected IRide getRide() {
		return ride;
	}

	/* (non-Javadoc)
	 * @see sourceFiles.IGate#openGate()
	 */
	public void openGate() {
		isOpened = true;
	}

	/* (non-Javadoc)
	 * @see sourceFiles.IGate#closeGate()
	 */
	public void closeGate() {
		isOpened = false;
	}

	/* (non-Javadoc)
	 * @see sourceFiles.IGate#passThroughGate(java.lang.Integer)
	 */
	public abstract void passThroughGate(Integer childID)
			throws RideActiveException, RideInactiveException, InvalidChildID,
			ChildAlreadyInRideException, ChildNotInRideException,
			ChildIDDoesntExist, InvalidRideId, ChildHeightDoesntMatch,
			ChildAgeDoesntMatch, ChildDoesntHaveTicket, RideIDDoesntExist,
			TicketDoesntExist;
}
